<template>
  <div class="OrderAddFrom">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="业务类型">
        <el-select v-model="inf.salesOrder.serviceId" placeholder="请选择业务类型">
          <el-option label="包年宽带" value=1></el-option>
          <el-option label="包月宽带" value=2></el-option>
        </el-select>
      </el-form-item>
      <el-form-item style="dispaly: flex">
        <el-button type="primary" @click="onSubmit">开通</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "OrderAddFrom",
  props: ["inf"],
  data() {
    return {
      
    };
  },
  
  methods: {
    onSubmit() {
      //   let _this = this;
      if(this.inf.salesOrder.serviceId == 1){
          this.inf.salesOrder.endTime = new Date(this.inf.salesOrder.startTime.getTime()+31536000000)
      }else if(this.inf.salesOrder.serviceId == 2){
          this.inf.salesOrder.endTime = new Date(this.inf.salesOrder.startTime.getTime()+2628000000)
      }

      this.$axios({
        url: "/order/addOrder",
        method: "post",
        data: this.inf,
      }).then(function (resp) {
        if(resp.data==1){
            alert("开通成功")
            location.reload();
        }else{
            alert("添加失败")
        }
      });
    },
  },
};
</script>